{% extends "base.html" %}

{% block title %}Schedule{% endblock %}
{% block content %}
{% load filters %}
<h1>Schedule</h1>
<p>
{% if prevGame %}
  <a href="/schedule/{{ prevGame.id }}">&lt;&lt; prev</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{% endif %}
 {{ date|date:"F j, Y" }} 
{% if nextGame %}
  <a href="/schedule/{{ nextGame.id }}">next &gt;&gt;</a>
{% endif %}
</p>

{% if gameList %}
<table width="100%">
  <tr style="font-weight:bold">
    <td>Sport</td>
    <td>Time</td>
    <td>Home</td>
    <td></td>
    <td>Away</td>
    <td>Location</td>
    <td>Referees</td>
  </tr>
{% autoescape off %}
{% for game in gameList %}
    <tr>
      <td>{{ game.game.League.Season.Sport }}</td>
      <td>{{ game.game.StartTime|date:"g:i" }}</td>
      <td class="{{game.homewin}}">{{ game.game.HomeTeam }}</td>
      <td>vs.</td>
      <td class="{{game.awaywin}}">{{ game.game.AwayTeam }}</td>
      <td>{{ game.game.Location }}</td>
      <td>
       {% for ref in game.game.Referees.all %}
         {{ ref }} {% if not forloop.last %},{% endif %}
       {% empty %}
         None
       {% endfor %}
      </td>
    </tr>
{% endfor %}
{% endautoescape %}
</table>
<p>
Home wears light, away wears dark
</p>
{% else %}
no games scheduled!!
{% endif %}
{% endblock %}
